﻿//线性代数

struct PTV3F
{
	float x;
	float y;
	float z;
};

struct PTV4F
{
	float x;
	float y; 
	float z;
	float w;
};

struct PTM44F
{
	PTV4F r[4];
};

struct PTSIMDVector;//列向量
struct PTSIMDMatrix;//作用于列向量行序为主序(内存布局等价于作用于行向量列序为主序)

enum PTIntersectionType
{
	PTDISJOINT = 0,//互斥
	PTINTERSECT = 1,//相交
	PTCONTAIN = 2,//包含
};

struct PTSIMDFrustum;
struct PTSIMDSphere;
struct PTSIMDAAB;
struct PTSIMDOB;

#if defined(PTX86) || defined(PTX64)
#include "SSE/PTMathSIMD.h"
#elif defined(PTARM) || defined(PTARM64)
#include "NEON/PTMathSIMD.h"
#else
#error 未知的架构
#endif

#if defined(PTWIN32)
#define PT_VECTORCALL __vectorcall
#elif defined(PTPOSIX)
#define PT_VECTORCALL __attribute__((vectorcall))
#else
#error 未知的平台
#endif

inline PTSIMDVector PT_VECTORCALL PTSIMDV3FLoad(const PTV3F *pSource);//x y z _

inline PTSIMDVector PT_VECTORCALL PTSIMDV3FLoadA(const PTV3F *pSource);//x y z _

inline void PT_VECTORCALL PSIMDV3FStore(PTV3F* pDestination, PTSIMDVector V);

inline void PT_VECTORCALL PSIMDV3FStoreA(PTV3F* pDestination, PTSIMDVector V);

inline PTSIMDVector PT_VECTORCALL PTSIMDV3FDot(PTSIMDVector V1, PTSIMDVector V2);

inline PTSIMDVector PT_VECTORCALL PTSIMDV3FCross(PTSIMDVector V1, PTSIMDVector V2);

inline PTSIMDVector PT_VECTORCALL PTSIMDV3FNormalize(PTSIMDVector V);

inline PTSIMDVector PT_VECTORCALL PTSIMDV4FLoad(const PTV4F *pSource);//x y z w

inline PTSIMDVector PT_VECTORCALL PTSIMDV4FLoadA(const PTV4F *pSource);//x y z w

inline void PT_VECTORCALL PTSIMDV4FStore(PTV4F* pDestination, PTSIMDVector V);

inline void PT_VECTORCALL PTSIMDV4FStoreA(PTV4F* pDestination, PTSIMDVector V);

inline PTSIMDVector PT_VECTORCALL PTSIMDV4FNegate(PTSIMDVector V);

inline PTSIMDVector PT_VECTORCALL PTSIMDV4FTransform(PTSIMDMatrix M, PTSIMDVector V);

inline void PT_VECTORCALL PTSIMDM44FStore(PTM44F* pDestination, PTSIMDMatrix M);

inline void PT_VECTORCALL PTSIMDM44FStoreA(PTM44F* pDestination, PTSIMDMatrix M);

inline PTSIMDMatrix PT_VECTORCALL PTSIMDM44FTranspose(PTSIMDMatrix M);

inline PTSIMDMatrix PT_VECTORCALL PTSIMDM44LookToRH(PTSIMDVector EyePosition, PTSIMDVector EyeDirection, PTSIMDVector UpDirection);

inline PTSIMDMatrix PT_VECTORCALL PTSIMDM44PerspectiveFovRH(float FovAngleY, float AspectHByW, float NearZ, float FarZ);

inline PTSIMDMatrix PT_VECTORCALL PTSIMDM44PerspectiveRH(float ViewWidth, float ViewHeight, float NearZ, float FarZ);

inline PTSIMDMatrix PT_VECTORCALL PTSIMDM44OrthographicRH(float ViewWidth, float ViewHeight, float NearZ, float FarZ);

inline PTSIMDMatrix PT_VECTORCALL PTSIMDM44Multiply(PTSIMDMatrix M1, PTSIMDMatrix M2);

inline PTSIMDFrustum PT_VECTORCALL PTSIMDFrustumLoadRH(PTSIMDMatrix ViewProjection);

inline PTSIMDSphere PT_VECTORCALL PTSIMDSphereLoad(PTV3F *pCenter,float Radius);

inline PTSIMDAAB PT_VECTORCALL PTSIMDAABBLoad(PTV3F *pMin, PTV3F *pMax);

//inline PTSIMDOB PT_VECTORCALL PTSIMDOBLoad(PTV3F *pCenter, PTV3F *pHalfDiagonal, PTSIMDMatrix Rotation);
//inline PTSIMDOB PT_VECTORCALL PTSIMDOBLoad(PTV3F *pCenter, PTV3F *pHalfDiagonal, PTV3F *pRotationXYZ);

inline PTIntersectionType PT_VECTORCALL PTSIMDFrustumSphereIntersect(PTSIMDFrustum F, PTSIMDSphere S);

inline PTIntersectionType PT_VECTORCALL PTSIMDFrustumAABIntersect(PTSIMDFrustum F, PTSIMDAAB AAB);

//inline PTIntersectionType PT_VECTORCALL PTSIMDFrustumOBIntersect(PTSIMDFrustum F, PTSIMDOB OB);

#if defined(PTX86) || defined(PTX64)
#include "SSE/PTMathSIMD.inl"
#elif defined(PTARM) || defined(PTARM64)
#include "NEON/PTMathSIMD.inl"
#else
#error 未知的架构
#endif